package com.gainloop.Listeners;

import java.util.LinkedList;

import com.gainloop.Adapters.TagAdapter;

import android.util.Log;
import android.view.View;

public class TagCancelButtonListener implements View.OnClickListener{
	LinkedList<String> _currentAddedTagsStr;
	String _tagName;
	TagAdapter _tagAdapter;
	
	public TagCancelButtonListener(LinkedList<String> _currentAddedTagsStr2, String tagNameStr, TagAdapter tagAdapter){
		Log.v("Tag Cancel Button Listener","created");
		_currentAddedTagsStr = _currentAddedTagsStr2;
		_tagName = tagNameStr;
		_tagAdapter = tagAdapter;
	}
	
	@Override
	public void onClick(View arg0) {
		Log.v("Tag Cancel Button Listener","clicked!");
		
		int i,loc;
		i=0;
		loc=0;
		for(String curTagName:_currentAddedTagsStr){
			if(curTagName.compareTo(_tagName)==0){
				loc=i;
				break;
			}	
			i++;
		}
		_currentAddedTagsStr.remove(loc);
		_tagAdapter.notifyDataSetChanged();
	}
	
}
